net/packet: fix overflow in tpacket_rcv
authorOr Cohen <orcohen@paloaltonetworks.com>
Fri, 4 Sep 2020 04:05:28 +0000 (21:05 -0700)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 5 Sep 2020 14:52:44 +0000 (15:52 +0100)
commite9b6f019fc6baabae76a5e24ee419760ce3c85a8
treefc4dc6bdf78784bf97f3a6e9701cd65f87d16483
parent04bd98169113e353e46dcc901b292b5c151941a7
net/packet: fix overflow in tpacket_rcv

Origin: https://git.kernel.org/linus/acf69c946233259ab4d64f8869d4037a198c7f06
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2020-14386

Using tp_reserve to calculate netoff can overflow as
tp_reserve is unsigned int and netoff is unsigned short.

This may lead to macoff receving a smaller value then
sizeof(struct virtio_net_hdr), and if po->has_vnet_hdr
is set, an out-of-bounds write will occur when
calling virtio_net_hdr_from_skb.

The bug is fixed by converting netoff to unsigned int
and checking if it exceeds USHRT_MAX.

This addresses CVE-2020-14386

Fixes: 8913336a7e8d ("packet: add PACKET_RESERVE sockopt")
Signed-off-by: Or Cohen <orcohen@paloaltonetworks.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name net-packet-fix-overflow-in-tpacket_rcv.patch
net/packet/af_packet.c